﻿using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SmartCity.Shared;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;

namespace ParkManagement
{
    /// <summary>
    /// 车辆控制器
    /// </summary>
    [Authorize]
    [RemoteService]
    [Area("commonManagement")]
    [Route("api/parkManagement/consumptions")]
    public class ConsumptionController : AbpController, IConsumptionAppService
    {
        private readonly IConsumptionAppService _consumptionAppService;

        public ConsumptionController(
            IConsumptionAppService consumptionAppService)
        {
            _consumptionAppService = consumptionAppService;
        }

        // 列表
        [HttpGet]
        [Route("")]
        public Task<ListResponse<ConsumptionDto>> ListAsync(string plateNo, string travelDate = null)
        {
            return _consumptionAppService.ListAsync(plateNo, travelDate);
        }

        // 创建
        [HttpPost]
        [Route("")]
        public Task<ActionResponse> CreateAsync(CreateConsumptionDto input)
        {
            return _consumptionAppService.CreateAsync(input);
        }

        // 更新
        [HttpPut]
        [Route("")]
        public Task<ActionResponse> UpdateAsync(UpdateConsumptionDto input)
        {
            return _consumptionAppService.UpdateAsync(input);
        }

        // 删除
        [HttpDelete]
        [Route("{id:int}")]
        public Task<ActionResponse> DeleteAsync(int id)
        {
            return _consumptionAppService.DeleteAsync(id);
        }
    }
}